package info.motteke.kurumi;

import info.motteke.mixivoice4j.BasicUpdateStrategy;
import info.motteke.mixivoice4j.MixiVoice;
import info.motteke.mixivoice4j.MixiVoiceException;
import info.motteke.mixivoice4j.UpdateStrategy;

import java.util.TimerTask;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;


public class MixiVoiceObserver extends TimerTask {

    private static final Log log = LogFactory.getLog(MixiVoiceObserver.class);

    private final MixiVoice mixi;

    private final UpdateStrategy strategy = new BasicUpdateStrategy();

    public MixiVoiceObserver(MixiVoice mixi){
        this.mixi = mixi;
    }

    @Override
    public void run() {
        try {
            mixi.update(strategy);
        } catch (MixiVoiceException e) {
            log.warn("エラー！", e);
        }
    }
}
